<!-- 首页 -->
<template>
	<view class="content">
		<view class="content-head"></view>
		<view class="conter">
			<view class="conter-title title1">{{$t("index.title1")}}</view>
			<view class="conter-title title2">{{$t("index.title2")}}</view>
			<!-- 退出登录 -->
			<view class="button" @click="loginOut">{{$t("login.out")}}</view>
			<view class="content-item" @click="handleInto">
				<view class="text">{{$t("index.into")}}</view>
				<image src="../../static/intobg.png" mode=""></image>
			</view>
			<view class="content-item" @click="handleOut" v-if="standing == 2">
				<view class="text">{{$t("index.out")}}</view>
				<image src="../../static/outbg.png" mode=""></image>
			</view>
			<view class="content-item" @click="handleSell">
				<view class="text">{{$t("index.sell")}}</view>
				<image src="../../static/outbg.png" mode=""></image>
			</view>
			<view class="content-item" @click="handleStock">
				<view class="text">{{$t("index.stock")}}</view>
				<image src="../../static/stockbg.png" mode=""></image>
			</view>
			<view class="content-item" @click="handleTransfer" v-if="standing == 3">
				<view class="text">{{$t("index.transfer")}}</view>
				<image src="../../static/intobg.png" mode=""></image>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title: 'Hello',
				standing: 0,
			}
		},
		onLoad() {
			this.standing = uni.getStorageSync("standing")
		},
		methods: {
			//库存
			handleStock(){
				let standing = uni.getStorageSync("standing")
				uni.navigateTo({
					url: "/pages/into/stock"
				})
			},
			// 入库
			handleInto() {
				let standing = uni.getStorageSync("standing")

				uni.navigateTo({
					url: "/pages/into/intoSelect"
				})
			},
			// 出库
			handleOut() {
				let standing = uni.getStorageSync("standing")
				if (standing == 1) {
					uni.navigateTo({
						url: "/pages/out/index?value=2"
					})
				} else {
					uni.navigateTo({
						url: "/pages/out/outSelect"
					})
				}
			},
			// 销售
			handleSell() {
				let standing = uni.getStorageSync("standing")
				if(standing==2){
					uni.navigateTo({
						url: "/pages/sell/sellSelect"
					})
				}else if(standing==3){
					uni.setStorageSync('shopCellCheckedData', '')
					uni.navigateTo({
						url: "/pages/sell/shop/sellSelectShop"
					})
				}
			},
			// 店铺之间调货
			handleTransfer() {
				uni.navigateTo({
					url: "/pages/transfer/transferSelect"
				})
			},
			// 退出登录
			loginOut() {
				uni.removeStorageSync("userInfo")
				uni.removeStorageSync("standing")
				uni.removeStorageSync("token")
				uni.removeStorageSync()
				uni.showModal({
					title: "Warm reminder",
					content: "Click OK to log out",
					cancelText: "cancel",
					confirmText: "confirm",
					success: (res) => {
						if (res.confirm) {
							uni.showToast({
								title: "exiting...",
								icon: "none"
							})
							setTimeout(() => {
								uni.reLaunch({
									url: "/pages/login/index"
								})
							}, 1300)
						}
					}
				})
			}

		}
	}
</script>

<style lang="scss" scoped>
	.content {
		background: linear-gradient(to right, rgba(#FF725F80, 0.5), rgba(#FFEBEB80, 0.5));
		height: 100vh;
		// display: flex;
		// justify-content: space-around;
		// align-items: center;
	}

	.content-head {
		width: 100vw;
		height: 88rpx;
	}

	.conter {
		height: 100%;
		background: #fff;
		border-radius: 20rpx 20rpx 0 0;
		padding: 60rpx 48rpx;

		.button {
			position: absolute;
			top: 148rpx;
			right: 48rpx;
			background: #FF725F;
			color: #fff;
			padding: 12rpx 20rpx;
			border-radius: 34rpx;
		}
	}

	.conter-title {
		font-size: 36rpx;
		font-weight: 900;
	}

	.title2 {
		margin-top: 22rpx;
		margin-bottom: 92rpx;
	}

	.content-item {
		width: 600rpx;
		height: 234rpx;
		text-align: center;
		line-height: 188rpx;
		border-radius: 20rpx;
		margin: 0 37rpx;
		margin-bottom: 90rpx;
		position: relative;

		.text {
			position: absolute;
			left: 46rpx;
			top: 50%;
			transform: translateY(-50%);
			z-index: 300;
			font-size: 48rpx;
			font-weight: 600;
		}

		image {
			width: 100%;
			height: 100%;
			position: absolute;
			left: 0;
			top: 0;
		}
	}
</style>